package com.thinkcoder.Interceptor.config;

import com.thinkcoder.Interceptor.AuthInterceptor;
import com.thinkcoder.service.impl.ZsetSerivceImpl;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    public AuthInterceptor authInterceptor(){
        return new AuthInterceptor();
    }


    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        //需要拦截的请求，/**表示所有请求
        String[] addPathPatterns={"/**"};
        //不需要拦截的请求
        String[] excludePathPatterns={"/user/gettoken/**"};

        registry.addInterceptor(authInterceptor())
                .excludePathPatterns(excludePathPatterns)
                .addPathPatterns(addPathPatterns);


    }
}
